<?php
include_once 'function-widget.php';
?>

<style type="text/css">
.advice{color:red;}
.slide{border-left:1px solid #efefef;}
#pub-carrossel-1{width:980px;height:auto;margin:auto;}
.pub-300x94{width:300px;height:94px;background-color:#efefef}
</style>

<?php		

// ========================================================================================================================================
// Bloco de notícias em destaque, mostra n notícia
// ========================================================================================================================================
class Pub300x94 extends WP_Widget {	

	function __construct(){
		parent::__construct('Pub300x94', 'AVPT_Publicidade - 300x94', array('description' => 'Mostra um bloco com uma publicidade 300x94'));
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);
		$title = empty ($instance['title']) ? 'Publicidade' : apply_filters('widget_title', $instance['title']);		
		$cod = empty ($instance['cod']) ? '0' : apply_filters('cod', $instance['cod']);  
		$up = empty ($instance['up']) ? '20' : apply_filters('up', $instance['up']);
		$down = empty ($instance['down']) ? '20' : apply_filters('down', $instance['down']);?>
		<div class="<?php echo 'vertical_space_'.$up?>"></div>
		<div id="pub-300x94">
			<span class="pub-retranca">PUBLICIDADE</span>
			<div class="pub-300x94"><?php echo $cod; ?></div>
		</div>
		<div class="<?php echo 'vertical_space_'.$down ?>"></div>
	<?php
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);		
		$instance['cod'] = $new_instance['cod'];
		$instance['up'] = strip_tags($new_instance['up']);
		$instance['down'] = strip_tags($new_instance['down']);
		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args((array) $instance, array('title' => '', 'cod' => '', 'up' => '', 'down' => ''));
		$title = strip_tags($instance['title']);
		$cod = $instance['cod'];
		$up = strip_tags($instance['up']);
		$down = strip_tags($instance['down']);
		?>
		<p>
		  <label for="<?php echo $this->get_field_id('title');?>"><?php _e('Título:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>">
		</p>		
		  <label for="<?php echo $this->get_field_id('cod');?>"><?php _e('Cod:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod'); ?>" name="<?php echo $this->get_field_name('cod'); ?>" value="<?php echo esc_attr($cod); ?>">
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('up');?>"><?php _e('Espaço acima em px:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('up'); ?>" name="<?php echo $this->get_field_name('up'); ?>" value="<?php echo esc_attr($up); ?>">
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('down');?>"><?php _e('Espaço abaixo em px:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('down'); ?>" name="<?php echo $this->get_field_name('down'); ?>" value="<?php echo esc_attr($down); ?>">
		</p>
		<?php		
	}
}
// ========================================================================================================================================







// ========================================================================================================================================
// Bloco de publicidade geral
// ========================================================================================================================================
class Pub_Geral extends WP_Widget {	

	function __construct(){
		parent::__construct('Pub_Geral', 'AVPT_Pub_Geral', array('description' => 'Mostra um bloco de publicidade com um tamanho padrão ou configurado'));
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);
		$title = empty ($instance['title']) ? 'Publicidade' : apply_filters('widget_title', $instance['title']);
		$altura = empty ($instance['altura']) ? '0' : apply_filters('altura', $instance['altura']); 
		$largura = empty ($instance['largura']) ? '0' : apply_filters('largura', $instance['largura']);
		$formato = empty ($instance['formato']) ? '0' : apply_filters('formato', $instance['formato']);
		$cod = empty ($instance['cod']) ? '0' : apply_filters('cod', $instance['cod']);  
		$up = empty ($instance['up']) ? '20' : apply_filters('up', $instance['up']);
		$down = empty ($instance['down']) ? '20' : apply_filters('down', $instance['down']);?>
		<div class="<?php echo 'vertical_space_'.$up?>"></div>
		<div id="pub-300x94">
			<span class="pub-retranca">PUBLICIDADE</span>
			<div class="pub-300x94"><?php echo $cod; ?></div>
		</div>
		<div class="<?php echo 'vertical_space_'.$down ?>"></div>
	<?php
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);		
		$instance['cod'] = $new_instance['cod'];
		$instance['altura'] = $new_instance['altura'];
		$instance['largura'] = $new_instance['largura'];		
		$instance['formato'] = $new_instance['formato'];
		$instance['up'] = strip_tags($new_instance['up']);
		$instance['down'] = strip_tags($new_instance['down']);
		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args((array) $instance, array('title' => '', 'cod' => '', 'altura' => '', 'largura' => '', 
			'formato' => '', 'up' => '', 'down' => ''));
		$title = strip_tags($instance['title']);
		$cod = $instance['cod'];
		$altura = strip_tags($instance['altura']);
		$largura = strip_tags($instance['largura']);
		$formato = strip_tags($instance['formato']);
		$up = strip_tags($instance['up']);
		$down = strip_tags($instance['down']);

		?>
		<p>
		  <label for="<?php echo $this->get_field_id('title');?>"><?php _e( 'Título: ' ) ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>">
		</p>		
		  <label for="<?php echo $this->get_field_id('cod');?>"><?php _e( 'Código: ' ) ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod'); ?>" name="<?php echo $this->get_field_name('cod'); ?>" value="<?php echo esc_attr($cod); ?>">
		</p>


		<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

		






		<p>
		  <label for="<?php echo $this->get_field_id('up');?>"><?php _e('Espaço acima em px:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('up'); ?>" name="<?php echo $this->get_field_name('up'); ?>" value="<?php echo esc_attr($up); ?>">
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('down');?>"><?php _e('Espaço abaixo em px:', 'tga') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('down'); ?>" name="<?php echo $this->get_field_name('down'); ?>" value="<?php echo esc_attr($down); ?>">
		</p>
		<?php		
	}
}
// ========================================================================================================================================







// ========================================================================================================================================
// Bloco de publicidade com um carrossel de 5 elementos na horizontal
// ========================================================================================================================================
class Pub_Carrossel_Um extends WP_Widget {

	function __construct(){
		parent::__construct('Pub_Carrossel_Um', 'AVPT_Publicidade - Carrossel 1', array('description' => 'Carrossel horizontal com peças de tamanho 178x100. Mínimo de 5 peças'));
	}

	function widget( $args, $instance ) {
		extract($args, EXTR_SKIP);
		$title = empty ($instance['title']) ? 'Publicidade' : apply_filters('widget_title', $instance['title']);
		
		$cod_1 = empty ($instance['cod_1']) ? '0' : apply_filters('cod_1', $instance['cod_1']);
		$cod_2 = empty ($instance['cod_2']) ? '0' : apply_filters('cod_2', $instance['cod_2']);
		$cod_3 = empty ($instance['cod_3']) ? '0' : apply_filters('cod_3', $instance['cod_3']);
		$cod_3 = empty ($instance['cod_3']) ? '0' : apply_filters('cod_4', $instance['cod_4']);
		$cod_5 = empty ($instance['cod_5']) ? '0' : apply_filters('cod_5', $instance['cod_5']);
		$cod_6 = empty ($instance['cod_6']) ? '0' : apply_filters('cod_6', $instance['cod_6']);
		$cod_7 = empty ($instance['cod_7']) ? '0' : apply_filters('cod_7', $instance['cod_7']);
		$cod_8 = empty ($instance['cod_8']) ? '0' : apply_filters('cod_8', $instance['cod_8']);
		$cod_9 = empty ($instance['cod_9']) ? '0' : apply_filters('cod_9', $instance['cod_9']);
		$cod_10 = empty ($instance['cod_10']) ? '0' : apply_filters('cod_10', $instance['cod_10']);
		
		$up = empty ($instance['up']) ? '10' : apply_filters('up', $instance['up']);
		$down = empty ($instance['down']) ? '10' : apply_filters('down', $instance['down']);?>

		<div class="<?php echo 'vertical_space_'.$up?>"></div>		

		<!-- Bloco com carrossel com 5 imagens 180x100 -->
		<div id="pub-carrossel-1">
			<script type="text/javascript">
			$(document).ready(function(){
			  $('.car_um').bxSlider({
			    slideWidth: 177,
			    minSlides: 5,
			    maxSlides: 5,
			    slideMargin: 8,
			    controls: true,
				pager: false 
			  });
			});
			</script>
			<div style="float:left;width:15px;height=120px;"></div>
			<div class="clr"></div>
			<div class="car_um">
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			  <div class="slide"><?php echo $cod_1; ?></div>
			</div>
		</div>
		<div class="vertical_space_30"></div>
		<!-- Bloco com carrossel com 5 imagens 180x100 -->

		<div class="<?php echo 'vertical_space_'.$down ?>"></div>

	<?php
	}

	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);

		$instance['cod_1'] = $new_instance['cod_1'];
		$instance['cod_2'] = $new_instance['cod_2'];
		$instance['cod_3'] = $new_instance['cod_3'];
		$instance['cod_4'] = $new_instance['cod_4'];
		$instance['cod_5'] = $new_instance['cod_5'];
		$instance['cod_6'] = $new_instance['cod_6'];
		$instance['cod_7'] = $new_instance['cod_7'];
		$instance['cod_8'] = $new_instance['cod_8'];
		$instance['cod_9'] = $new_instance['cod_9'];
		$instance['cod_10'] = $new_instance['cod_10'];
		
		$instance['up'] = strip_tags($new_instance['up']);
		$instance['down'] = strip_tags($new_instance['down']);
		return $instance;
	}

	function form( $instance ) {
		$instance = wp_parse_args((array) $instance, array('title' => '', 'qtde' => '', 'cod_1' => '', 'cod_2' => '', 'cod_3' => '',
			'cod_4' => '', 'cod_5' => '', 'cod_6' => '', 'cod_7' => '', 'cod_8' => '', 'cod_9' => '', 'cod_10' => '', 'up' => '', 'down' => ''));
		$title = strip_tags($instance['title']);

		$cod_1 = $instance['cod_1'];
		$cod_2 = $instance['cod_2'];
		$cod_3 = $instance['cod_3'];
		$cod_4 = $instance['cod_4'];
		$cod_5 = $instance['cod_5'];
		$cod_6 = $instance['cod_6'];
		$cod_7 = $instance['cod_7'];
		$cod_8 = $instance['cod_8'];
		$cod_9 = $instance['cod_9'];
		$cod_10 = $instance['cod_10'];
		
		$up = strip_tags($instance['up']);
		$down = strip_tags($instance['down']);
		?>
		<p>
		  <label for="<?php echo $this->get_field_id('title');?>"><?php _e('Título: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_1');?>"><?php _e('Código 1: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_1'); ?>" name="<?php echo $this->get_field_name('cod_1'); ?>" value="<?php echo esc_attr($cod_1); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_2');?>"><?php _e('Código 2: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_2'); ?>" name="<?php echo $this->get_field_name('cod_2'); ?>" value="<?php echo esc_attr($cod_2); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_3');?>"><?php _e('Código 3: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_3'); ?>" name="<?php echo $this->get_field_name('cod_3'); ?>" value="<?php echo esc_attr($cod_3); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_4');?>"><?php _e('Código 4: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_4'); ?>" name="<?php echo $this->get_field_name('cod_4'); ?>" value="<?php echo esc_attr($cod_4); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_5');?>"><?php _e('Código 5: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_5'); ?>" name="<?php echo $this->get_field_name('cod_5'); ?>" value="<?php echo esc_attr($cod_5); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_6');?>"><?php _e('Código 6: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_6'); ?>" name="<?php echo $this->get_field_name('cod_6'); ?>" value="<?php echo esc_attr($cod_6); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_7');?>"><?php _e('Código 7: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_7'); ?>" name="<?php echo $this->get_field_name('cod_7'); ?>" value="<?php echo esc_attr($cod_7); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_8');?>"><?php _e('Código 8: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_8'); ?>" name="<?php echo $this->get_field_name('cod_8'); ?>" value="<?php echo esc_attr($cod_8); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_9');?>"><?php _e('Código 9: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_9'); ?>" name="<?php echo $this->get_field_name('cod_9'); ?>" value="<?php echo esc_attr($cod_9); ?>">
		</p>
		<p>		
		  <label for="<?php echo $this->get_field_id('cod_10');?>"><?php _e('Código 10: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('cod_10'); ?>" name="<?php echo $this->get_field_name('cod_10'); ?>" value="<?php echo esc_attr($cod_10); ?>">
		</p>		
		<p>
		  <label for="<?php echo $this->get_field_id('up');?>"><?php _e('Espaço acima em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('up'); ?>" name="<?php echo $this->get_field_name('up'); ?>" value="<?php echo esc_attr($up); ?>">
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('down');?>"><?php _e('Espaço abaixo em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('down'); ?>" name="<?php echo $this->get_field_name('down'); ?>" value="<?php echo esc_attr($down); ?>">
		</p>
		<?php		
	}
}
// ========================================================================================================================================














